﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Acms.Bll;
using System.Web.UI;

namespace Acms.AcmsControls.ContentControls.FrontEnd
{
    /// <summary>
    /// Renders the Display name of the current / containing (if in datacontrol with datasource of posts) posts
    /// </summary>
    public class PostDisplayName : BasePostPropertyControl
    {

        public override void DataBind()
        {
            Post p = FindCurrentPost();
            if (p != null)
            {
                Text = p.DisplayName;
            }
            else
            {
                Text = "Display Name Here";
            }
            base.DataBind();
        }


        public string Text { get; set; }

        protected override object SaveViewState()
        {
            ViewState["Text"] = Text;
            return base.SaveViewState();
        }

        protected override void LoadViewState(object savedState)
        {
            base.LoadViewState(savedState);
            Text = ViewState["Text"] as string;
        }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            writer.Write(Text);
        }
    }
}
